<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

<title>请登录</title>

<link href="../css/login.css" rel="stylesheet" type="text/css" />
<link href="../plugin/sweetalert-6.6.2/sweetalert2.min.css" rel="stylesheet" type="text/css" />
</head>
<body onkeydown="key_login();">
	<h1 onclick="show()">请登录</h1>
	<div class="login-form">
		<div class="close" onclick="hide()"></div>
		<div class="head-info">
			<label class="lbl-1"> </label> <label class="lbl-2"> </label> <label class="lbl-3"> </label>
		</div>
		<div class="clear"></div>
		<div class="avtar">
			<img src="../images/avtar.png" />
		</div>
		<form>
			<input type="text" class="text" placeholder="请输入用户名" id="login_staff_username">
			<div class="key">
				<input type="password" placeholder="请输入密码" id="login_staff_password">
			</div>
		</form>
		<div class="signin">
			<input id="form_login" type="submit" value="登录" onclick="toLogin()">
		</div>
	</div>
</body>
<script src='../plugin/jquery-3.2.1/jquery-3.2.1.min.js'></script>
<script src='../plugin/sweetalert-6.6.2/sweetalert2.min.js'></script>
<script src='../plugin/soul/utils.js'></script>
<script src='../js/base.js'></script>
<script>
	if (window.top !== window.self) {
		window.top.location = window.location;
	}
	function key_login() {
		if (event.keyCode == 13) {//回车键的键值为13
			// event.returnValue = false;
            // window.event.returnValue= false;
			// event.cancel = true;
			// toLogin();
            // return false;
            $("#form_login").click(); //调用登录按钮的登录事件
		}
	}

	function hide() {
		$('.login-form').hide();
	}
	function show() {
		$('.login-form').show();
	}
	//去登录
	function toLogin() {
		// 判断空
		var username = $("#login_staff_username").val();
		if (username == "") {
			SwalUtil.error('请输入用户名');
			return;
		}
		var password = $("#login_staff_password").val();
		if (password == "") {
			SwalUtil.error('请输入密码');
			return;
		}

		var resp = AjaxUtil.postJson("staff/login", {
			username : username,
			password : password
		});
		if (resp) {
			window.localStorage.token = resp.obj.token;
			SwalUtil.success('登录成功,正在跳转...');
			setTimeout(function() {
				// 延时2s后执行
				window.location.href = 'index.html';
			}, 2000);
		}
		return false;
	}
</script>
</html>